package com.lqs;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Twotest {
	public static void main(String[] args) {
		
	int[] stuCore = {53,78,96,66,85};
	int max = stuCore[0];
	int min = stuCore[0];
	int average = 0;
	int sum = 0;
	for(int i=0;i<stuCore.length;i++){
	if(max<stuCore[i]){
	max = stuCore[i];
	}
	if(min>stuCore[i]){
	min = stuCore[i];
	}
	sum += stuCore[i];
	}
	average = sum/stuCore.length;
	System.out.println("最大值是："+max);
	System.out.println("最小值是："+min);
	System.out.println("所有值之和："+sum);
	System.out.println("平均值是："+average);
	
	System.out.print("\n");
	String[] stuNo={"2019011535","2019011534","2019011539","2019011538","2019011537"};
    HashMap map = new HashMap();
    System.out.print("排序前："+Arrays.toString(stuNo));
    for (int i = 0; i < stuNo.length; i++) {   	
        map.put(stuNo[i], i);// 将值和下标存入Map 
    }

    // 排列
    List list = new ArrayList();
    Arrays.sort(stuNo); // 升序排列
    for (int i = 0; i < stuNo.length; i++) {
        list.add(stuNo[i]);
    }
//        System.out.print("\n");
        System.out.print("\n"+"排序后：");
    for (Object object : list) {
        System.out.print(object + ",");
    }
    /*// 查找原始下标
    for (int i = 0; i < n; i++) {
        System.out.print(map.get(stuNo[i]) + ",");
    }*/
         System.out.println();
    	
	String[] stuName={"张三","李四","王五","赵六","王九"};
    HashMap mapp = new HashMap();
    System.out.print("排序前："+Arrays.toString(stuName));
    for (int i = 0; i < stuName.length; i++) {   	
        map.put(stuName[i], i);// 将值和下标存入Map 
    }

    // 排列
    List lists = new ArrayList();
    Arrays.sort(stuName); // 升序排列
    for (int i = 0; i < stuName.length; i++) {
        lists.add(stuName[i]);
    }
    System.out.print("\n");
        System.out.print("排序后：");
    for (Object object : lists) {
        System.out.print(object + ",");
    }
    System.out.print("\n");
   
    HashMap maps = new HashMap();
    System.out.print("排序前："+Arrays.toString(stuCore));
    for (int i = 0; i < stuCore.length; i++) {   	
        maps.put(stuCore[i], i);// 将值和下标存入Map 
    }

    // 排列
    List listss = new ArrayList();
    Arrays.sort(stuCore); // 升序排列
    for (int i = 0; i < stuCore.length; i++) {
        listss.add(stuCore[i]);
    }       
        System.out.print("\n"+"排序后：");
    for (Object object : listss) {     
        System.out.print(object + ",");
    }
        System.out.print("\n");
    
//将list集合取出
       Object[] arr = list.toArray();
//       for (int i = 0; i < arr.length; i++) {
         //  String e = (String) arr[i];
        //   System.out.print(e+",");
                     
//使用copyOf复制数组   
    Object[] b = (Object[])Arrays.copyOf(arr,arr.length);
	//  Arrays.copyOf(arr,b,arr.length);
      System.out.print("新数组：");
	for(int j=0;j<b.length;j++){
	  System.out.print(b[j]+" ");
	  
}
	System.out.print("\n");
//将list集合取出
    Object[] arr1 = lists.toArray();      
//使用copyOf复制数组   
    Object[] a = (Object[])Arrays.copyOf(arr1,arr1.length);
      System.out.print("新数组：");
	for(int j=0;j<a.length;j++){
	  System.out.print(a[j]+" ");
}
	  System.out.print("\n");
	//将list集合取出
    Object[] arr2 = listss.toArray();      
//使用copyOf复制数组   
    Object[] c =(Object[])Arrays.copyOf(arr2,arr2.length);
//    System.arraycopy(arr2, 0, c, 0, arr.length);
      System.out.print("新数组：");
	for(int j=0;j<c.length;j++){
	  System.out.print(c[j]+" ");
}
}
}

	

    
    
    
	
	
	
